package xin.fsqr520.project.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xin.fsqr520.project.domain.po.News;
import xin.fsqr520.project.domain.vo.Result;
import xin.fsqr520.project.mapper.NewsMapper;

import java.util.List;

@RestController
@RequestMapping("/news")
public class NewsController {

    @Autowired
    private NewsMapper newsMapper;

    @GetMapping("/getAllNews")
    public Result<?> getAllNews() {
        List<News> newsList = newsMapper.selectList(new LambdaQueryWrapper<News>().orderByAsc(News::getNewsTime));
        return Result.success(newsList);
    }
}
